import java.util.ArrayList;
import java.util.List;

import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.shape.Line;


public class TreeConMenu extends ContextMenu 
{
	private Label parent;

	private List<TreeConMenu> menuChildren = new ArrayList<TreeConMenu>();
	
	private List<Line> attachedLines = new ArrayList<Line>();
	
	private boolean isParentTrans;
	
	
	
	public TreeConMenu ()
	{
		super();
	}

	
	public boolean isParentTrans() 
	{
		return isParentTrans;
	}



	public void setParentTrans(boolean isParentTrans) 
	{
		this.isParentTrans = isParentTrans;
	}
	
	
	
	public Label getParent() 
	{
		return parent;
	}

	
	
	public void setParent(Label parent) 
	{
		this.parent = parent;
	}
	
	

	public List<Line> getAttachedLines() 
	{
		return attachedLines;
	}


	
	public void addAttachedLine(Line attachedLine) 
	{
		this.attachedLines.add(attachedLine);
	}
	
	
	
	public List<TreeConMenu> getMenuChildren() 
	{
		return menuChildren;
	}



	public void addMenuChild(TreeConMenu child) 
	{
		this.menuChildren.add(child);
		realign();
		
		for (TreeConMenu menuChild : menuChildren) 
		{
			menuChild.realign();
		}
	}

	
	
	private void realign()
	{
		int offset = 1 - menuChildren.size();
		for (TreeConMenu child : menuChildren) 
		{
			child.getParent().setLayoutX(parent.getLayoutX() + 70 * offset);
			offset = offset + 2;
		}
	}
}
